package com.neu.ui;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.neu.R;

/**
 * 基础的fragement
 */
public abstract  class BaseFragment extends Fragment {
    //日志信息
    protected final String TAG="TAG";
    public Context context;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
       View view=inflater.inflate(layoutId(),container,false);
       initView(view);
       initData();
       return view;
    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        this.context=context;
    }

    //定义抽象方法
    //绑定xml
    protected abstract int layoutId();

    /**
     * 初始化对象
     * 获得对象的引用
     */
    protected abstract void initView(View view);

    /**
     * 数据绑定
     */
    protected abstract void initData();
}